﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace project3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入要测试2-？的整数：");
            int N = int.Parse(Console.ReadLine());
            int[] array = new int[N];
            for (int i = 0; i < N; i++)
            {
                array[i] = i + 1;//为数组赋值 用于测试
            }
            prime Primenum = new prime();
            Primenum.fun(array);
            Console.WriteLine("2-{0}内的素数有", N);
            for(int i = 0;i < N; i++)
            {
                if(array[i] != -1 && i!=0)
                {
                    Console.Write("{0} ", array[i]);
                }
            }
            Console.ReadKey();
        }
    }

    class prime
    {
        public void fun(int[] array)
        {
            for(int temp = 2; temp < array.Length; temp++)
            {
                for(int j = 0; j < array.Length; j++)
                {
                    if(array[j]%temp == 0 && array[j] > temp)
                    {
                        array[j] = -1;
                    }
                }
            }
        }
    }
}
